package com.duguyuan.service;

import com.duguyuan.dao.UserDao;
import com.duguyuan.dao.UserDaoImpl;
import com.duguyuan.entity.User;

public class UserServiceImpl implements UserService {

    private UserDao userDao = new UserDaoImpl();


    @Override
    public int register(User user) {
        if (userDao.findByUsername(user.getUsername())) {
            return 0;
        }else {
            userDao.insertUser(user);
            return 1;
        }
    }

    @Override
    public User login(String username, String password) {
        return userDao.findUserOne(username, password);
    }
}
